package cn.tedu.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.CopyOnWriteArrayList;

public class JDBCUtils {

    /**
     * 用于关闭数据库连接的资源关闭工具
     * 单独jian类来实现
     */

    public static void close(ResultSet re, PreparedStatement pt, Connection conn){
        if (re != null) {
            try {
                re.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                re=null;
            }
        }

        if (pt != null) {
            try {
                pt.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                pt=null;
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }finally {
                conn=null;
            }
        }


    }

}
